From 493a79e990b03016faa61adc2c6790a5debe93eb Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Wed, 27 Dec 2000 15:46:17 +0000 Subject: [PATCH] (Frecenter): Use displayed_window_lines instead of window_internal_height. --- src/window.c | 97 ++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/src/window.c b/src/window.c index f2af5e3305a..c148598ae62 100644 --- a/src/window.c +++ b/src/window.c @@ -4433,6 +4433,54 @@ Default for ARG is window width minus 2.") - XINT (arg))); } + +/* Value is the number of lines actually displayed in window W, + as opposed to its height. */ + +static int +displayed_window_lines (w) + struct window *w; +{ + struct it it; + struct text_pos start; + int height = window_box_height (w); + struct buffer *old_buffer; + int bottom_y; + + if (XBUFFER (w->buffer) != current_buffer) + { + old_buffer = current_buffer; + set_buffer_internal (XBUFFER (w->buffer)); + } + else + old_buffer = NULL; + + SET_TEXT_POS_FROM_MARKER (start, w->start); + start_display (&it, w, start); + move_it_vertically (&it, height); + + if (old_buffer) + set_buffer_internal (old_buffer); + + bottom_y = it.current_y + it.max_ascent + it.max_descent; + + if (bottom_y > it.current_y && bottom_y <= it.last_visible_y) + /* Hit a line without a terminating newline. */ + it.vpos++; + + /* Add in empty lines at the bottom of the window. */ + if (bottom_y < height) + { + struct frame *f = XFRAME (w->frame); + int rest = height - bottom_y; + int lines = rest / CANON_Y_UNIT (f); + it.vpos += lines; + } + + return it.vpos; +} + + DEFUN ("recenter", Frecenter, Srecenter, 0, 1, "P", "Center point in window and redisplay frame. With ARG, put point on line ARG.\n\ The desired position of point is always relative to the current window.\n\ @@ -4443,7 +4491,7 @@ redraws with point in the center of the current window.") register Lisp_Object arg; { register struct window *w = XWINDOW (selected_window); - register int ht = window_internal_height (w); + register int ht = displayed_window_lines (w); struct position pos; struct buffer *buf = XBUFFER (w->buffer); struct buffer *obuf = current_buffer; @@ -4488,53 +4536,6 @@ redraws with point in the center of the current window.") } -/* Value is the number of lines actually displayed in window W, - as opposed to its height. */ - -static int -displayed_window_lines (w) - struct window *w; -{ - struct it it; - struct text_pos start; - int height = window_box_height (w); - struct buffer *old_buffer; - int bottom_y; - - if (XBUFFER (w->buffer) != current_buffer) - { - old_buffer = current_buffer; - set_buffer_internal (XBUFFER (w->buffer)); - } - else - old_buffer = NULL; - - SET_TEXT_POS_FROM_MARKER (start, w->start); - start_display (&it, w, start); - move_it_vertically (&it, height); - - if (old_buffer) - set_buffer_internal (old_buffer); - - bottom_y = it.current_y + it.max_ascent + it.max_descent; - - if (bottom_y > it.current_y && bottom_y <= it.last_visible_y) - /* Hit a line without a terminating newline. */ - it.vpos++; - - /* Add in empty lines at the bottom of the window. */ - if (bottom_y < height) - { - struct frame *f = XFRAME (w->frame); - int rest = height - bottom_y; - int lines = rest / CANON_Y_UNIT (f); - it.vpos += lines; - } - - return it.vpos; -} - - DEFUN ("window-text-height", Fwindow_text_height, Swindow_text_height, 0, 1, 0, "Return the height in lines of the text display area of WINDOW.\n\ -- 2.30.2